/* eslint valid-jsdoc: 'off' */

const jwt = {
    secret: "qiyejia_server",
};

const cors = {
    origin: "*",
    allowMethods: "GET, PUT, POST, DELETE, PATCH",
};

const isLinuxEnvironment = require('os').platform() === 'linux';

if (isLinuxEnvironment) {
    host = 'mysql';
    username = 'root';
    password = '91vDQhMgF9wzZlYf/MTUiZzAebT9D8Yi';
} else {
    host = 'localhost';
    username = 'wjffff';
    password = 'wjffff';
}

const mysqlConfig = {
    host,
    port: 3306,
    username,
    password
};
const schedule = {
    tasks: {
        cleanupExpiredTokens: {
            //   schedule: '0 2 * * *', // 这里可以省略，因为已经在任务类中定义

        },
    },
};


const logger = {
    level: "INFO",
    type: "dateFile",
    console: true,
    disableConsoleAfterReady: false,
    output: "both",
};

const security = {
    csrf: {
        enable: false,
    },
};



module.exports = (appInfo) => {

    const config = (exports = {});

    const data = {
        keys: appInfo.name + "_1716451288095_8483",
        jwt,
        cors,
        schedule,
        security,
        logger,
        sequelize: {
            dialect: 'mysql',
            dialect: "mysql",
            ...mysqlConfig,
            timezone: '+08:00',
            database: 'server',
            define: {
                // 使用自定义的表名
                freezeTableName: true,
                // 自动生成时间戳 -小驼峰式
                timestamps: true,
                // 表名小驼峰
                underscored: false,
            },
        },
    };

    return {
        ...config,
        ...data,
    };
};
